home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_11 / 9n11099a < prev    next >
Text File  |  1991-04-11  |  2KB  |  91 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *       file d:\cips\mainedge.c
  5.        *
  6.        *       Functions: This file contains
  7.        *          main
  8.        *
  9.        *       Purpose:
  10.        *          This file contains the main calling
  11.        *          routine in an edge detection program.
  12.        *
  13.        *       External Calls:
  14.        *          gin.c - get_image_name
  15.        *          numcvrt.c - get_integer
  16.        *                      int_convert
  17.        *          tiff.c - read_tiff_header
  18.        *          edge.c - quick_edge
  19.        *
  20.        *       Modifications:
  21.        *          2 February 1991 - created
  22.        *
  23.        *************************************************/
  24.  
  25. #include "d:\cips\cips.h"
  26.  
  27.  
  28.  
  29. short the_image[ROWS][COLS];
  30. short out_image[ROWS][COLS];
  31.  
  32. main(argc, argv)
  33.    int argc;
  34.    char *argv[];
  35. {
  36.  
  37.    char name[80], name2[80];
  38.  
  39.    int  count, i, ie, il, j, le, length, ll, t, type, v, width;
  40.  
  41.  
  42.    struct   tiff_header_struct image_header;
  43.  
  44.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  45.    _setbkcolor(1);
  46.    _settextcolor(7);
  47.    _clearscreen(_GCLEARSCREEN);
  48.  
  49.    if(argc < 6){
  50.     printf("\n\nNot enough parameters:");
  51.     printf("\n   usage: mainedge   in-file   out-file   type ");
  52.     printf("  threshold?   threshold-value");
  53.     printf("\n   recall type: 1-Prewitt 2-Kirsch 3-Sobel 4-quick");
  54.     printf("\n   threshold?   1-threshold on   2-threshold off\n");
  55.     exit(0);
  56.    }
  57.  
  58.    strcpy(name, argv[1]);
  59.    strcpy(name2, argv[2]);
  60.    int_convert(argv[3], &type);
  61.    int_convert(argv[4], &t);
  62.    int_convert(argv[5], &v);
  63.  
  64.    il = 1;
  65.    ie = 1;
  66.    ll = ROWS+1;
  67.    le = COLS+1;
  68.  
  69.    read_tiff_header(name, &image_header);
  70.  
  71.    length = (90 + image_header.image_length)/ROWS;
  72.    width  = (90 +image_header.image_width)/COLS;
  73.    count  = 1;
  74.    printf("\nlength=%d  width=%d", length, width);
  75.  
  76.    for(i=0; i<length; i++){
  77.       for(j=0; j<width; j++){
  78.         printf("\nrunning %d of %d", count, length*width);
  79.         count++;
  80.         if(type == 4)
  81.            quick_edge(name, name2, the_image, out_image,
  82.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  83.                       le+j*COLS, t, v);
  84.         else
  85.            detect_edges(name, name2, the_image, out_image,
  86.                         il+i*ROWS, ie+j*COLS, ll+i*ROWS, 
  87.                         le+j*COLS, type, t, v);
  88.       }
  89.    }
  90.  
  91. }  /* ends main  */